package likou;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: 唐小尊
 * @email: 1171702529@qq.com
 * @cate: 2021/05/15 11:41
 */
public class _77 {
    public static void main(String[] args) {
        System.out.println(combine(4,2));
    }
    static List<List<Integer>> res = new ArrayList<>();
    public static List<List<Integer>> combine(int n, int k) {
        dfs(new ArrayList<>(),n,k,1);
        return res;
    }
    public static void dfs(List<Integer> now,int n,int k,int index){
        if (now.size()==k){
            res.add(new ArrayList<>(now));
            return;
        }
        if (index>n){
            return;
        }
        for (int i = index;i<=n;i++){
            now.add(i);
            dfs(now,n,k,i+1);
            now.remove(now.size()-1);
        }
    }
}
